********************************************
*** Code for Roberts Impeachment Project ***
***          Armaly & Enders             ***
***										 ***
***   .do file originated 29 Jan 2021.   ***
********************************************

set more off

import excel "anonymized.xlsx", sheet("Roberts+impeachment_March+5,+20") firstrow case(lower) clear

** duration & obserations
drop if duration < 100
drop if random > 4


***********
* partisanship and ideology

gen pid1 = q10
gen pid2rep = q12
gen pid2dem = q14
gen pid2ind = q16

gen pid = -3 if pid2dem == 1
replace pid = -2 if pid2dem == 2
replace pid = -1 if pid2ind == 2
replace pid = 0 if pid2ind == 3
replace pid = 0 if pid2ind == 4
replace pid = 1 if pid2ind == 1
replace pid = 2 if pid2rep == 2
replace pid = 3 if pid2rep == 1

gen pidstrength = abs(pid)

gen pid3 = pid
recode pid3 -3 = 1 -2 = 1 -1 = 1 0 = 2 1 = 3 2 = 3 3 = 3

gen repub = .
replace repub = 0 if pid < 0
replace repub = 1 if pid > 0 & pid < . 

gen ideo = q43
recode ideo (1=-3) (2=-2) (3=-1) (4=0) (5=1) (6=2) (7=3)

gen ideostrength = abs(ideo)

gen ideo3 = ideo
recode ideo3  (-3 = 1) (-2 = 1) (-1 = 1) (0 = 2) (1 = 3) (2 = 3) (3 = 3)


gen sorting = abs(ideo - (-1*pid)) * (ideostrength * pidstrength)


***********
** treatment indicator

gen treatment = random
label define treatment 0 "control" 1 "JGR admonish" 2 "JGR ignore protocol" ///
	3 "Whistleblower" 4 "E. Warren Q" 
label values treatment treatment
tab treatment


********
* acceptance & diffuse support

gen acceptance = q38

foreach var of varlist q33_1-q33_7{
	replace `var' = 6-`var'
}
*
alpha q33_1-q33_7, gen(legitimacy)


*******
* demographics

gen female = .
replace female = 0 if q127 == 1
replace female = 1 if q127 == 2

gen hispanic = .
replace hispanic = 0 if q129 == 2
replace hispanic = 1 if q129 == 1

gen white = .
replace white = 0 if q131_1 == .
replace white = 1 if q131_1 == 1

gen black = .
replace black = 0 if q131_2 == .
replace black = 1 if q131_2 == 1

*gen age = q133

gen educ = q135

gen south = 0
replace south = 1 if q137 == 3

*******
* Rescale variables 0-1
foreach v of var acceptance legitimacy  {
	su `v', meanonly 
	gen `v'2 = (`v' - r(min))/(r(max) - r(min)) 
}
*



************** JGR's actions

* additive
reg acceptance2  i.treatment i.pid3 if treatment < 4
margins, over(treatment)

reg legitimacy2  i.treatment i.pid3 if treatment < 4
margins, over(treatment)

** interactive
reg acceptance2  i.treatment##i.pid3 if treatment < 4
margins, dydx(treatment) over(pid3)

reg legitimacy2  i.treatment##i.pid3 if treatment < 4
margins, dydx(treatment) over(pid3)



****** Warren's "attack" 

reg acceptance2  i.treatment i.pid3 if treatment == 0 | treatment == 4
reg legitimacy2  i.treatment i.pid3  if treatment == 0 | treatment == 4


reg acceptance2  i.treatment##i.pid3 if treatment == 0 | treatment == 4
reg legitimacy2  i.treatment##i.pid3  if treatment == 0 | treatment == 4



